package sk.uniza.fri.cerviix.client.network.message.server;

import java.io.IOException;

import sk.uniza.fri.cerviix.client.Game;
import sk.uniza.fri.cerviix.client.game.Player;
import sk.uniza.fri.cerviix.client.network.ServerMessage;

public class PlayerAddMessage extends ServerMessage
{
	private int playerId;
	private String playerName;
	
	@Override
	public void receive() throws IOException
	{
		playerId = stream.readInt();
		playerName = stream.readUTF();
	}
	
	public void run(Game game)
	{		
		Player player = new Player(playerId);
		player.setName(playerName);
		
		game.addPlayer(player);
	}
}
